package com.example.taximeter.mapper;

import com.example.taximeter.bean.Price;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 价格类别
 */
@Mapper
public interface PriceMapper {

    //查询价格类别列表
    @Select("select id , price_type from tab_dict_price_type")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "pricetype", column = "price_type")
    })
    List<Price> findPriceList();

    //查询价格类型(价格类型)
    @Select("select id , price_type from tab_dict_price_type where price_type = #{pricetype,jdbcType=VARCHAR} ")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "pricetype", column = "price_type")
    })
    List<Price> findPriceByPriceType(@Param("pricetype") String pricetype);

    //新增价格类型
    @Insert("insert into tab_dict_price_type (price_type,memo)\n" +
            "    values (#{pricetype,jdbcType=VARCHAR}, #{memo,jdbcType=VARCHAR}) ")
    Boolean addPrice(Price price);

    //修改价格类型
    @Update("update tab_dict_price_type set price_type = #{pricetype,jdbcType=VARCHAR},memo = #{memo,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER}")
    boolean updatePrice(Price price);

    //删除价格类型
    @Delete("delete from tab_dict_price_type  where id = #{id,jdbcType=INTEGER}")
    boolean deletePrice(Integer id);

    //查询价格类型列表
    @SelectProvider(type = ActivityMapperProvider.class, method = "findPriceAll")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "pricetype", column = "price_type"),
            @Result(property = "memo", column = "memo")

    })
    List<Price> findPriceAll(Price price);

    //查询价格类型(id)
    @Select("select price_type from tab_dict_price_type where id = #{id,jdbcType=INTEGER} ")
    @Results({
            @Result(property = "pricetype", column = "price_type")
    })
    String findPricetypeByPriceid(@Param("id") Integer id);
}
